package com.itheima.dubbo.mysql.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itheima.commons.pojo.domain.SoulQuestionOption;
import com.itheima.commons.vo.reception.OptionsVo;
import com.itheima.dubbo.interfaces.SoulQuestionOptionApi;
import com.itheima.dubbo.mysql.mapper.SoulQuestionOptionMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.WeakHashMap;
@Service
public class SoulQuestionOptionApiImpl  implements SoulQuestionOptionApi {
    @Autowired
    SoulQuestionOptionMapper soulQuestionOptionMapper;

    @Override
    public SoulQuestionOption findOneByQueIdAndOpt(Long questionId, Long optionId) {
       return soulQuestionOptionMapper.selectOne(Wrappers.lambdaQuery(SoulQuestionOption.class)
                .eq(SoulQuestionOption::getQuestionId,questionId)
                .eq(SoulQuestionOption::getId,optionId)
        );
    }

    @Override
    public SoulQuestionOption findOneByQueId(Long optionId) {
        return soulQuestionOptionMapper.selectOne(Wrappers.lambdaQuery(SoulQuestionOption.class)
                .eq(SoulQuestionOption::getId,optionId));
    }

    @Override
    public List<SoulQuestionOption> findAllOptionByQuestionId(Long toLong) {
     return    soulQuestionOptionMapper.selectList(Wrappers.lambdaQuery(SoulQuestionOption.class)
                .eq(SoulQuestionOption::getQuestionId,toLong));
    }
}
